package models

import (
	"go.uber.org/zap"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"

	"2106a-zg5/demo/user/user_srv/global"
	"2106a-zg5/demo/user/user_srv/initPkg"
)

func init() {
	initPkg.NacosInit()
	initPkg.LoggerInit()
	dsn := global.UserConfig.Mysql
	var err error
	global.DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		zap.S().Debug("Mysql error: ", err)
		return
	}
	global.DB.Debug()
	zap.S().Info("Mysql Database successfully")
}
